package com.jingmi.jingmiliving.commodity.service.impl;

import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jingmi.common.utils.PageUtils;
import com.jingmi.common.utils.Query;

import com.jingmi.jingmiliving.commodity.dao.AttrAttrgroupRelationDao;
import com.jingmi.jingmiliving.commodity.entity.AttrAttrgroupRelationEntity;
import com.jingmi.jingmiliving.commodity.service.AttrAttrgroupRelationService;


@Service("attrAttrgroupRelationService")
public class AttrAttrgroupRelationServiceImpl extends ServiceImpl<AttrAttrgroupRelationDao, AttrAttrgroupRelationEntity> implements AttrAttrgroupRelationService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<AttrAttrgroupRelationEntity> page = this.page(
                new Query<AttrAttrgroupRelationEntity>().getPage(params),
                new QueryWrapper<AttrAttrgroupRelationEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<AttrAttrgroupRelationEntity> selectByAttrId(Long[] attrId) {
        System.out.println("selectByAttrId ids===>"+attrId[0]);
        QueryWrapper<AttrAttrgroupRelationEntity> attrAttrgroupRelationEntityQueryWrapper = new QueryWrapper<>();
        attrAttrgroupRelationEntityQueryWrapper.in("attr_id",attrId);
        List<AttrAttrgroupRelationEntity> list = this.list(attrAttrgroupRelationEntityQueryWrapper);
        System.out.println("LIST===>"+list);

        return list;
    }

    @Override
    public List<AttrAttrgroupRelationEntity> selectByGroupId(Long groupId) {
        QueryWrapper<AttrAttrgroupRelationEntity> attrAttrgroupRelationEntityQueryWrapper = new QueryWrapper<>();
        attrAttrgroupRelationEntityQueryWrapper.eq("attr_group_id",groupId);
        List<AttrAttrgroupRelationEntity> list = this.list(attrAttrgroupRelationEntityQueryWrapper);
        System.out.println("LIST===>"+list);

        return list;
    }

}